#!/bin/bash
echo -e "\nWelcome to the qgetopts testing library\n=======================================\n"

# Initialise before running the tests

   # remove the coverage directory and any *.info files
   rm coverage/object/optionManager/*.html
   rm coverage/*.png
   rm coverage/*.html
   rm coverage/*.css
   rm lcov_tmp/*.info

   lcov -z -d object/ -q

   # generate a blank coverage file
   lcov -c -i  -d object/ -o lcov_tmp/qgetopt_base.info -q
   lcov -e lcov_tmp/qgetopt_base.info "*optionManager/opt*" -o lcov_tmp/qgetopt_base.info -q
   
# Run the tests
cd object/
./test2
cd ../

# generate the coverage data from the unit tests
echo -e "\nGenerating the unit test coverage rate\n"

lcov -c -d object/ -o lcov_tmp/qgetopt_utest.info -t unitTests -q
lcov -e lcov_tmp/qgetopt_utest.info "*optionManager/opt*" -o lcov_tmp/qgetopt_utest.info -q
lcov -a lcov_tmp/qgetopt_base.info -a lcov_tmp/qgetopt_utest.info  -a lcov_tmp/qgetopt_test.info -o lcov_tmp/qgetopt_total_coverage.info -q

# Generate the html report from the tests
echo -e "\nGenerating the HTML report\n==========================\n"

genhtml -o ./coverage lcov_tmp/qgetopt_total_coverage.info -t "qgetopt test coverage" -s
